package com.efuture.io;

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;

/**
 * @ClassNAME DataInputStreamTest
 * @Description DataInputStream的基本使用 数据输入流
 * @Author zhaoshanshan
 * @Date 2021/9/8 8:48 下午
 * @Version 1.0
 * 读取写入数据类型的专属流 读的顺序必须跟写的顺序一致
 */
public class DataInputStreamTest {

    public static void main(String[] args) {
        DataInputStream dis = null;
        try{
            dis = new DataInputStream(new FileInputStream("javasestudy/src/com.efuture.io/DataOutputStream"));
//            dos.writeByte(b);
//            dos.write(i);
//            dos.writeFloat(f);
//            dos.writeDouble(d);
//            dos.writeBoolean(flag);
//            dos.writeLong(l);
//            dos.writeShort(sh);
            byte b = dis.readByte();
            int i = dis.read();
            float f = dis.readFloat();
            double d = dis.readDouble();
            boolean flag = dis.readBoolean() ;
            long l = dis.readLong();
            short sh =  dis.readShort();
            System.out.println(b);
            System.out.println(i);
            System.out.println(f);
            System.out.println(d);
            System.out.println(flag);
            System.out.println(l);
            System.out.println(sh);
        }catch (Exception e){
            e.getStackTrace();
        }finally {
            if(null!=dis){
                try {
                    dis.close();
                    dis = null;
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }
}